<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>订单管理页面</title>
    <link rel="stylesheet" href="/css/site.min.css"/>
    <link rel="stylesheet" href="/css/style.css"/>
    <script src="/js/jquery-1.11.3.js"></script>
    <script src="/js/bootstrap.min.js"></script>
</head>
<body>
<a href='javascript:void(0);' onclick="logOut()" class='close'
   style="float: right;margin-right: 5%;height: 3em;padding-top: 8px;">退出</a>
<!--导航栏-->
<div style="text-align: center;color: #ff4d4d;"><h1>订单管理</h1></div>
<!--订单管理页面-->
<div class="container" style="margin-top: 0%;color: #000;">
    <!--添加信息-->
    <a href="../addOrder"><input class="navbar-left close" type="button" style="width:8em;height:3em;" value="添加订单"></a>

    <!--搜索框-->
    <form class="navbar-form navbar-right" role="search" style="margin-right: 5em;" action="../order" method="get">
        <div class="form-group">
            <input type="text" name="searchName" style="border-radius: 20px 0 0 20px;" class="form-control"
                   value="<%= orderid %>" placeholder="输入订单编号或前几位">
        </div>
        <input type="submit" class="close"
               style="height:2.3em;border-radius: 0 20px 20px 0;margin-top: -2px;margin-left: -3px;z-index: 5;"
               value="查询">
    </form>
    <!--信息表-->

    <div class="">
        <form action="/cancelOrder" method="post">
            <table class="table" style="border:1px solid #eee;margin-top: 3%;background-color:#ff4d4d;">
                <tr>
                    <th style="width:9%">订单编号</th>
                    <th style="width:9%">区域</th>
                    <th style="width:7%">支付类型</th>
                    <th style="width:7%">订单金额</th>
                    <th style="width:7%">收货人</th>
                    <th style="width:7%">联系电话</th>
                    <th style="width:6%">快递员</th>
                    <th style="width:8%">快递员电话</th>
                    <th style="width:10%">订单状态</th>
                    <th style="width:11%">下单时间</th>
                    <th style="width:8%">备注</th>
                </tr>
                <tbody>
                <% for(var i = 0;i < orderList.length;i++){
                    var str = "";
                    if (orderList[i].status == 1000) {
                        str = "已创建、未付款";
                    } else if (orderList[i].status == 2000) {
                        str = "已付款、未审核";
                    } else if (orderList[i].status == 2500) {
                        str = "已审核、未出单";
                    } else if (orderList[i].status == 3000) {
                        str = "已出单、未打包";
                    } else if (orderList[i].status == 4000) {
                        str = "已打包、未中转";
                    } else if (orderList[i].status == 4500) {
                        str = "已中转、未抵达";
                    } else if (orderList[i].status == 5000) {
                        str = "已抵达、未分配";
                    } else if (orderList[i].status == 6000) {
                        str = "已分配、未领件";
                    } else if (orderList[i].status == 7000) {
                        str = "已领件、未派送";
                    } else if (orderList[i].status == 8000) {
                        str = "已派送、未签收";
                    } else if (orderList[i].status == 9000) {
                        str = "已签收、未评价";
                    } else if (orderList[i].status == 9001) {
                        str = "退货待受理";
                    } else if (orderList[i].status == 9002) {
                        str = "退货受理中";
                    } else if (orderList[i].status == 9003) {
                        str = "退货已受理";
                    } else if (orderList[i].status == 9999) {
                        str = "已评价";
                    } else if (orderList[i].status == -1) {
                        str = "订单用户取消";
                    } else if (orderList[i].status == -2) {
                        str = "订单平台取消";
                    } %>
                <tr>
                    <td style="width:9%"><%= orderList[i].orderID %></td>
                    <td style="width:9%"><%= orderList[i].areaName %></td>
                    <td style="width:7%"><%= orderList[i].payway %></td>
                    <td style="width:7%"><%= orderList[i].total %></td>
                    <td style="width:7%"><%= orderList[i].name %></td>
                    <td style="width:7%"><%= orderList[i].phone %></td>
                    <td style="width:6%"><%= orderList[i].messionedUser %></td>
                    <td style="width:8%"><%= orderList[i].messionedUserPhone %></td>
                    <td style="width:10%"><%= str %></td>
                    <td style="width:11%"><%= orderList[i].createdAt %></td>
                    <td style="width:8%">
                        <a href="../detail?orderid=<%= orderList[i].orderID %>"><input class="close_1"
                                                                                       type="button"
                                                                                       style="height:1.7em;line-height:1em;width: 36px; font-size: 13px;"
                                                                                       value="详情"></a> <input
                                class="close_1"
                                type="submit"
                                style="height:1.7em;line-height:1em;width: 36px; font-size: 13px;"
                                value="撤销" orderid="<%= orderList[i].orderID %>" onclick="return cancelOrder(event)"></a>
                    </td>
                </tr>
                <% } %>
                </tbody>
            </table>
            <input id="hidOrderID" name="hidOrderID" type="hidden"/>
        </form>
        <div style="text-align: center;">
            <ul class="pagination" id="pagination">
                <!--<li>-->
                <!--<a href="#" aria-label="Previous">-->
                <!--<span aria-hidden="true">&laquo;</span>-->
                <!--</a>-->
                <!--<>-->
                <!--<li><a href="#">1</a><>-->
                <!--<li><a href="#">2</a><>-->
                <!--<li><a href="#">3</a><>-->
                <!--<li><a href="#">4</a><>-->
                <!--<li><a href="#">5</a><>-->
                <!--<li>-->
                <!--<a href="#" aria-label="Next">-->
                <!--<span aria-hidden="true">&raquo;</span>-->
                <!--</a>-->
                <!--<>-->
            </ul>
        </div>

    </div>

</div>
<script>
    function cancelOrder(event) {
        if (confirm("快递员未接的订单可以撤销，确定撤销该订单吗")) {
            event = event ? event : window.event;
            var obj = event.srcElement ? event.srcElement : event.target;
            var orderid = $(obj).attr("orderid");
            $("#hidOrderID").val(orderid);
            return true;
        } else {
            return false;
        }
    }
    $(document).ready(function () {
        var cancelFlag = '<%=cancelFlag%>';
        if (cancelFlag == -1) {
            alert("该订单已被快递员抢单，无法撤销，请联系果然100");
        }

        if ($("#pagination")) {
            var pagecount = '<%=count%>';
            var pagesize = '<%=pagesize%>';
            var currentpage = '<%=pageIndex%>';
            var counts, pagehtml = "";
            if (pagecount % pagesize == 0) {
                counts = parseInt(pagecount / pagesize);
            } else {
                counts = parseInt(pagecount / pagesize) + 1;
            }
            //只有一页内容
            if (pagecount <= pagesize) {
                pagehtml = "";
            }
            //大于一页内容
            if (pagecount > pagesize) {
                if (currentpage > 1) {
                    pagehtml += "<li><a href='../order/" + (parseInt(currentpage - 1)) + "'>上一页</a></li>";
                }
                for (var i = 0; i < counts; i++) {
                    if (i >= (currentpage - 3) && i < (currentpage + 3)) {
                        if (i == currentpage - 1) {
                            pagehtml += '<li class="active"><a href="../order/' + (i + 1) + '">' + (i + 1) + '</a></li>';
                        } else {
                            pagehtml += '<li><a href="../order/' + (i + 1) + '">' + (i + 1) + '</a></li>';
                        }

                    }
                }
                if (currentpage < counts) {
                    pagehtml += '<li><a href="../order/' + (parseInt(currentpage) + 1) + '">下一页</a></li>';
                }
            }
            $("#pagination").html(pagehtml);
        }
    });
    function logOut() {
        top.location.href = "../../index/9999";
    }
</script>
</body>
</html>
